import os
import pytest
from tools.read_excel_range_as_list_of_dictionary import read_excel_range_as_list_of_dictionary



@pytest.mark.parametrize("input_range, expected_keys,expected_rows", [
    ("A1:B2", ['A', 'B'],2),       # 两列两行
    ("C5:C5", ['C'],1),            # 单单元格
    ("D3:F5", ['D', 'E', 'F'],3),  # 三列多行
])
def test_read_excel_range_as_list_of_dictionary(input_range, expected_keys,expected_rows):
    file_path = os.path.join(os.path.dirname(__file__), "read_excel_range_as_list_of_dictionary_test_data.xlsx")
    sheet_name = "TestSheet"
    result = read_excel_range_as_list_of_dictionary(file_path, sheet_name,input_range)
    assert list(result[0].keys()) == expected_keys
    assert len(result) == expected_rows




